package cn.com.idmy.auth.context;


import lombok.AllArgsConstructor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Map;

@AllArgsConstructor
public class StorageForThreadLocal implements Storage {
    @NotNull
    protected final Map<String, Object> map;

    @Override
    public @NotNull Object source() {
        return map;
    }

    @Override
    public @NotNull StorageForThreadLocal set(@NotNull String key, @NotNull Object value) {
        map.put(key, value);
        return this;
    }

    @Override
    public @Nullable Object get(@NotNull String key) {
        return map.get(key);
    }

    @Override
    public @NotNull StorageForThreadLocal remove(@NotNull String key) {
        map.remove(key);
        return this;
    }
}
